/*! \file tests.c
 *
 *  \brief Functions for the test suite over the library.
 */
#include "tests.h"

/*! \brief Get the time with ms precision.
 *
 *  \return number of milliseconds since the UNIX epoch.
 * 
 *  Returns the amount of milliseconds elapsed since the UNIX epoch. Useful to
 *  measure time lapses that occur in a few milliseconds.
 * 
 *  \note Works on both windows and linux.
 */
int64 getTime(void)
{
    /* Linux */
    struct timeval tv;

    gettimeofday(&tv, NULL);

    uint64 ret = tv.tv_usec;
    /* Convert from micro seconds (10^-6) to milliseconds (10^-3) */
    ret /= 1000;

    /* Adds the seconds (10^0) after converting them to milliseconds (10^-3) */
    ret += (tv.tv_sec * 1000);

    return ret;
}